package com.wondersgroup.retrofittest.login;

import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v7.widget.AppCompatButton;
import android.support.v7.widget.AppCompatEditText;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import com.hss.mvp.base.BaseMVPFragment;
import com.wondersgroup.retrofittest.R;
import com.wondersgroup.retrofittest.login.contract.ILoginContract;

import butterknife.Bind;
import butterknife.ButterKnife;
import butterknife.OnClick;

/**
 * Created by Administrator on 2017/2/9.
 */

public class LoginFragment extends BaseMVPFragment<ILoginContract.Presenter> implements ILoginContract.View {


    @Bind(R.id.et_name)
    AppCompatEditText etName;
    @Bind(R.id.et_pwd)
    AppCompatEditText etPwd;
    @Bind(R.id.btn_login)
    AppCompatButton btnLogin;

    @Nullable
    @Override
    public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        View root = inflater.inflate(R.layout.fragment_login, container, false);
        ButterKnife.bind(this, root);
        return root;
    }


    @Override
    public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
        super.onViewCreated(view, savedInstanceState);
//        etName.setText("13301668320");
        etName.setText("13524286150");
        etPwd.setText("111111");
    }

//    @Override
//    public void onResume() {
//        super.onResume();
//        presenter.attachView(this);
//    }
//
//
//    @Override
//    public void onStop() {
//        super.onStop();
//        presenter.detachView();
//    }

    @Override
    public void setLoginName(String name) {

    }

    @Override
    public String getLoginPwd() {
        return etPwd.getText().toString().trim();
    }

    @Override
    public String getLoginName() {
        return etName.getText().toString().trim();
    }





    @Override
    public void showMSVLoading() {

    }

    @Override
    public void showMSVEmpty() {

    }

    @Override
    public void showMSVNetErr() {

    }

    @Override
    public void showMSVUnknowErr() {

    }

    @Override
    public void showMSVContent() {

    }


    @Override
    public void onDestroyView() {
        super.onDestroyView();
        ButterKnife.unbind(this);
    }

    @OnClick(R.id.btn_login)
    public void onClick() {
        presenter.login(getLoginName(),getLoginPwd());
    }
}
